<template>
	<view>
		<u-tabbar :value="tabValue" :placeholder="false"
			@change="changeTab" :fixed="true"
			:safeAreaInsetBottom="false" activeColor="#00518a">
			<u-tabbar-item text="首页" icon="home" name="1" dot/>
			<u-tabbar-item text="积分" icon="grid" name="2" badge="3"/>
			<u-tabbar-item text="我的" icon="account" name="3" />
		</u-tabbar>
	</view>
</template>

<script>
export default {
	name: 'index',
	props: {},
	components:{ },
	computed: {
		getters: function(){
			return this.$store.getters
		}
	},
	data() {
		return {
			tabValue: '1',  //tab项，从1开始
		}
	},
	mounted() {
		const tabIdx = this.getters.tabBarIndex;
		if(tabIdx != null && tabIdx != undefined){
			this.tabValue = tabIdx.toString();
		}
	},
	methods: {
		//点击 tab
		changeTab(name){
			this.tabValue = name
			this.$store.commit('setTabBarIndex', name)
		}
	},
}
</script>

<style lang="scss" scoped></style>